package com.xn.app.muying.adpter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xn.app.muying.R;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/10/16.
 */
public class HomeXuanChuanListViewAdaper extends BaseAdapter {

    private Context context;
    private LayoutInflater inflater;
    private ArrayList<String> list = new ArrayList();


    public HomeXuanChuanListViewAdaper(Context context, ArrayList<String> list) {
        this.context = context;
        this.list = list;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {

        ViewHoler_XuanChuan_ListView viewHoler_xuanChuan_listView = new ViewHoler_XuanChuan_ListView();

        if (view == null) {
            view = inflater.inflate(R.layout.item_xuanchuan_listview, null);
            viewHoler_xuanChuan_listView.textView = (TextView) view.findViewById(R.id.xuanchuan_listview_tv);
            view.setTag(viewHoler_xuanChuan_listView);
        } else {
            viewHoler_xuanChuan_listView = (ViewHoler_XuanChuan_ListView) view.getTag();
        }

        viewHoler_xuanChuan_listView.textView.setText(list.get(position).toString());

        return view;
    }
}

class ViewHoler_XuanChuan_ListView {

    TextView textView;

}